/**
 * 用户详情对话框（可用于添加和修改对话框）
 */
var RefundsAuditDlg = {
    width: '680px',
    height: 'auto',
    currentLayerIndex: -1,
    cache: ""
};

/**
 * 初始化新增弹出框
 */
RefundsAuditDlg.init = function () {
    this.cache = $("#refundsAuditDlg").html();
    $("#refundsAuditDlg").html('');
};

/**
 * 关闭此对话框
 */
RefundsAuditDlg.close = function () {
    layer.close(this.currentLayerIndex);
};

/**
 * 打开模态框调用事件
 * 初始化
 */
RefundsAuditDlg.renderAdd = function () {
    //初始化
};

/**
 * 退款审核信息
 */
RefundsAuditDlg.refundsAudit = function (row) {
    $("#txt_refundId").val(row.id);
    $("#txt_refundCourseName").html(row.refundCourseName);
    $("#txt_coursePurchaseTimes").html(row.coursePurchaseTimes);
    $("#txt_orderNum").html(row.orderNum);
    $("#txt_courseAmount").html(numeral(row.courseAmount).format('0,0.00'));
    $("#txt_refundsReason").html(row.refundsReason);
};
/**
 * 退款审核提交
 */
RefundsAuditDlg.refundsAuditSubmit = function () {
    var option = {
        refundId: $("#txt_refundId").val(),
        refundsNum: $("#txt_refundsNum").val(),
        refundsAmount: $("#txt_refundsPrice").val()
    };
    var ajax = new $ax(Feng.ctxPath + "/refunds/refundsAudit", function (data) {
        if (data.success) {
            Feng.success("操作成功");
            RefundsTable.me.refresh();
        } else if (data.code === 2) {
            Feng.error(data.msg);
        } else {
            Feng.error("操作失败!");
        }
    }, function (data) {
        Feng.error("加载信息失败!");
    });
    ajax.setData(option);
    ajax.start();
};

/**
 * 取消退款
 */
RefundsAuditDlg.cancelRefunds = function (id) {
    var ajax = new $ax(Feng.ctxPath + "/refunds/cancelRefunds", function (data) {
        Feng.log("取消退款申请成功");
        if (data.success) {
            Feng.success("操作成功！");
        } else if (data.code === "2") {
            Feng.error(data.msg);
        } else {
            Feng.error("操作失败!");
        }
    }, function (data) {
        Feng.error("加载信息失败!");
    });
    ajax.data = {refundsId: id};
    ajax.start();
};